from sqlalchemy import Column, INTEGER, DATETIME, TEXT
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_dm import VARCHAR2, DATE, NUMBER

# 创建对象的基类
Base = declarative_base()

# 报告配置类
class SysReportConfigModel(Base):
    # 模式名
    __table_args__ = {'schema': 'ESUNTEST'}
    # 表名
    __tablename__ = 'HX_SYS_REPORT_CONFIG'

    ID=Column(VARCHAR2(200), primary_key=True)
    REPORT_ID=Column(VARCHAR2(200))
    REPORT_KEY=Column(VARCHAR2(400))
    REPORT_VALUE=Column(TEXT)
    CREATE_DATE=Column(DATE)
    IS_DELETE = Column(INTEGER)

    @classmethod
    def from_dict(cls, data):
        return cls(
            ID=data['ID'],
            REPORT_ID=data['REPORT_ID'],
            REPORT_KEY=data['REPORT_KEY'],
            REPORT_VALUE=data['REPORT_VALUE'],
            CREATE_DATE=data['CREATE_DATE'],
            IS_DELETE=data['IS_DELETE']
        )

    def to_dict(self):
        return {
            'ID': self.ID,
            'REPORT_ID': self.REPORT_ID,
            'REPORT_KEY': self.REPORT_KEY,
            'REPORT_VALUE': self.REPORT_VALUE,
            'CREATE_DATE': self.CREATE_DATE,
            'IS_DELETE': self.IS_DELETE
        }